﻿using DataCenter_DataBase;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using KeaoBase;

namespace DataCenter.Models.WeiXin
{
    public class WeiXinMsg:BaseWeiXinMsg
    {

        private ApiDataBase m_Api;
        public WeiXinMsg(KeaoXmlHelper XmlHelper):base(XmlHelper)
        {
            this.Content = XmlHelper.GetFirstNodeInnerString("Content");
            this.MsgId = XmlHelper.GetFirstNodeInnerValue<long>("MsgId");
            m_Api = new ApiDataBase();
        }

        public string Content { get; set; }
        public long? MsgId { get; set; }


        public override string ResponseResult()
        {
            if (Content.Contains("你好") || Content.Contains("您好"))
            {
                return ReturnTextMsg("您好。");
            }

            tbl_weixin_user item = m_Api.GetWeiXinUserByOpenId(FromUserName);
            if (item != null)
            {
                if (item.expires_time > DateTime.Today)
                {
                    return ReturnTextMsg("您好，您的授权已超过有效期。");
                }
            }
            else
            {
                return ReturnTextMsg("您好，您还不是授权用户。");
            }

            return ReturnTextMsg("您好，产品正在紧张研发中...\n请耐心等待。");

        }

    }
}